package com.pengweiwei.androidzygote.functions.media;

import android.content.Context;
import android.content.Intent;

import com.pengweiwei.androidzygote.R;

/**
 * Created by Administrator on 2017/9/15.
 */

public class AudioPlayer {


    public static void playRing(Context context) {
        play(context, new CharactAudio(R.raw.ring, CharactAudio.PLAY_TYPE_FOLLOW, CharactAudio.PRIORITY_STANDARD, true));
    }

    public static void playCallUser(Context context) {
        play(context, new CharactAudio(R.raw.callingsuser, CharactAudio.PLAY_TYPE_NORMAL, CharactAudio.PRIORITY_HIGH));
    }


    public static void playNetworkEnable(Context context) {
        play(context, new CharactAudio(R.raw.network_enabled, CharactAudio.PLAY_TYPE_FOLLOW, CharactAudio.PRIORITY_STANDARD));
    }


    public static void playRes(Context context, int res) {
        play(context, new CharactAudio(res, CharactAudio.PLAY_TYPE_NORMAL, CharactAudio.PRIORITY_STANDARD));
    }



    public static void play(Context context, CharactAudio audio) {
        Intent intent = new Intent(context, AudioPlayerService.class);
        intent.setAction(AudioPlayerService.ACTION_PLAY);
        intent.putExtra("newAudio", audio);
        context.startService(intent);
    }


    public static void stop(Context context) {
        Intent intent = new Intent(context, AudioPlayerService.class);
        intent.setAction(AudioPlayerService.ACTION_STOP);
        context.startService(intent);
    }
}
